#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int t,n,a,k[N],mi=N,ma;
long long ans=0;
int main(){
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	cin>>t;
	while(t--){
		cin>>n;
		for(int i=1;i<=n;i++){
			cin>>a;
			ma=max(ma,a);
			mi=min(mi,a);
			k[a]++;
		}
		for(int i=mi;i<=ma;i++){
			ans+=(k[i]/2)*i;
		}
		cout<<ans<<endl;
		memset(k,0,sizeof(k));
		ans=0;
		mi=N;
		ma=0;
	}
    return 0;
}
